package com.kmgames.ballsengine.models;

import java.util.Hashtable;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g3d.loaders.wavefront.ObjLoader;
import com.badlogic.gdx.graphics.g3d.model.still.StillModel;

public class ModelLoader {
	public static Hashtable<String, StillModel> models = new Hashtable<String, StillModel>();

	public static StillModel getObj(String objPath) {
		if (!models.containsKey(objPath)) {
			models.put(objPath, loadObj(objPath));
		}

		return models.get(objPath);
	}

	public static void dispose() {
		for (StillModel model : models.values()) {
			model.dispose();
		}

		models.clear();
	}

	private static StillModel loadObj(String objPath) {
		return new ObjLoader().loadObj(Gdx.files.internal(objPath));
	}
}
